#include<bits/stdc++.h>
using namespace std;

const int inf=114514810;
int n,m,a,b,bel[150010][310],hd[150010],cnt,q[150010],l,r,tot,x,y,dis[150010],Dis[150010];
unsigned long long bo[600010][9];
struct node{int to,next,la;}e[600010];
vector<int> v[150010],V[150010];

int read()
{
	int p=0; char c=getchar();
	while (c>'9'||c<'0') c=getchar();
	while (c>='0'&&c<='9') p=p*10+c-48,c=getchar();
	return p;
}

void del(int x,int i)
{
	if (i==hd[x]) hd[x]=e[i].next,e[hd[x]].la=0;
	else e[e[i].next].la=e[i].la,e[e[i].la].next=e[i].next;
}

int main()
{
	freopen("edge.in","r",stdin);
	freopen("edge.out","w",stdout);
	n=read(),m=read(),a=read(),b=read();
	for (int i=1; i<=m; i++) 
	{
		x=read(),y=read();
		e[++cnt]=(node){y,hd[x],0},e[hd[x]].la=cnt,hd[x]=cnt;
		v[y].push_back(cnt),V[x].push_back(y);
		e[++cnt]=(node){x,hd[y],0},e[hd[y]].la=cnt,hd[y]=cnt;
		v[x].push_back(cnt),V[y].push_back(x);
		if (!bel[x][y>>9]) bel[x][y>>9]=(++tot);
		bo[bel[x][y>>9]][(y&511)>>6]|=(1ull<<(y&63));
		if (!bel[y][x>>9]) bel[y][x>>9]=(++tot);
		bo[bel[y][x>>9]][(x&511)>>6]|=(1ull<<(x&63));
	}
	for (int i=1; i<=n; i++) dis[i]=Dis[i]=inf;
	q[l=r=1]=1,Dis[1]=0;
	while (l<=r)
	{
		x=q[l++];
		for (int i=hd[x]; i; i=e[i].next)
			if (Dis[e[i].to]==inf) Dis[q[++r]=e[i].to]=Dis[x]+1;
	}
	if (a*2<b)
	{
		for (int i=2; i<=n; i++) printf("%lld\n",1ll*Dis[i]*a);
		return 0;
	}
	q[l=r=1]=1,dis[1]=0;
	for (int k=0,Sz=v[1].size(); k<Sz; k++) del(V[1][k],v[1][k]);
	while (l<=r)
	{
		x=q[l++];
		for (int i=0,j,sz=V[x].size(); i<sz; i++)
			for (j=hd[V[x][i]],y=e[j].to; j; j=e[j].next,y=e[j].to)
				if (!bel[x][y>>9]||!(bo[bel[x][y>>9]][(y&511)>>6]>>(y&63)&1))
				{
					dis[q[++r]=y]=dis[x]+1;
					for (int k=0,Sz=v[y].size(); k<Sz; k++) del(V[y][k],v[y][k]);
				}
	}
	for (int i=2; i<=n; i++) 
		printf("%lld\n",min(1ll*dis[i]*(dis[i]==inf?inf:b),1ll*(Dis[i]>>1)*b+(Dis[i]&1)*a));
	return 0;
}
